package com.elsa.smart_buffet.controller;

import com.alibaba.fastjson.JSON;
import com.elsa.smart_buffet.mapper.CalorieTableMapper;
import com.elsa.smart_buffet.pojo.ResultBox.ResponseResult;
import com.elsa.smart_buffet.service.CalorieService;
import com.elsa.smart_buffet.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : CalorieController  //类名
 * @Author : elsa //作者
 */
@RestController
@CrossOrigin
public class CalorieController {

    @Autowired
    private MenuService menuService;

    @Autowired
    private CalorieService calorieService;

    @PostMapping("/getCategorySumByTimeAndCategory")
    public ResponseResult getCategorySumByTimeAndCategory(@RequestBody String data) {
        return menuService.selectClassifyTable(JSON.parseObject(data).get("data").toString());
    }

    @PostMapping("/getCalorieTableByTime")
    public ResponseResult getCalorieTableByTime(@RequestBody String data) {
        return calorieService.getCalorieTableByTime(JSON.parseObject(data).get("data").toString());
    }

}
